//PITCH PROGRAM
//CLASS: Player 
//	- Abstract class from which subclasses AI_Player
//	and Human_Player extend from
//BY: ALEX TRACY
import java.util.Arrays;
import java.awt.image.*;
public abstract class Player 
{
	
	 
	 private int hand[] = new int[6]; //hand of cards
	 private int bestSuit; //players best suit for bidding
	 private int bid; //players bid
	 private BufferedImage cards[] = new BufferedImage[6];//images of cards
	 private int index;//index of player
	 PlayerPanel pPanel;//panel of card images
	 private int team;//team player is on
	 
	//Player constructor sets each card in hand
	//to a card that doesn't exist, sets players team
	//and players index
	public Player(int id)
	{
		for (int i = 0 ; i < 6 ; i++)
			hand[i] = -1;
		index = id;
		if (index % 2 == 0)
		{
			pPanel = new PlayerPanel(this,true);
			team = 0;
		}
		else
		{
			pPanel = new PlayerPanel(this,false);
			team= 1;
		}
	}//End Constructor
	
	
	//method to determine a players bid
	public abstract void determineBid(int h);
	//method to determine players best bid suit
	public abstract void determineBidS();
	public abstract int play(int[] played,int led,int trump,int turn, int boss, boolean jackOut, 
			boolean twoOut, int hN);
	public abstract boolean isHuman();
	public abstract void initPanel();
	
	
	
	//method to get bid from player
	public int bid(int high)
	{
		determineBid(high);
		return getBid();
	}//End bid
	
	//return players bid amount
	public int getBid()
	{
		return bid;
	}//End getBid
	
	//return players bid suit
	public int getBidS()
	{
		determineBidS();
		return bestSuit;
	}//End getBidS
	
	//set players bid 
	public void setBid(int n)
	{
		bid = n;
	}//End setBid
	  
	//set players bid suit
	public void setBidS(int n)
	{
		bestSuit = n;
	}//End setBidS
	
	//setHand
	//set a card in the hand
	public void setHand(int count, int c)
	{
		hand[count] = c;
	}//End setHand
		
	//sortHand
	//Sort cards in hand from smallest to largest
	public void sortHand()
	{
		Arrays.sort(hand);
	}//End sortHand
		
	//return a specified card in hand
	public int getCard(int n)
	{
		return hand[n];
	}//End getCard
		
	//return players entire hand
	public int[] getHand()
	{
		return hand;
	}//End getHand
	
	//return bufferimages of cards
	public BufferedImage[] getCardsImgArray()
	{
		return cards;
	}//End getCardsImgArray
	
	//return specified image of card
	public BufferedImage getCardImage(int c)
	{
		return cards[c];
	}//End getCardImage
	
	//set specified card image to specified buffered image
	public void setCardImage(int i,BufferedImage b)
	{
		cards[i] = b;
	}//End setCardImage
		
	//set index of player
	public void setPlayerIndex(int i)
	{
		index = i;
	}//End setPlayerIndex
		
	//get index of player
	public int getPlayerIndex()
	{
		return index;
	}//End getPlayerIndex
	
	//get index of players partner
	public int getPartnerIndex()
	{
		if (getPlayerIndex() < 2)
			return getPlayerIndex() + 2;
		else
			return getPlayerIndex() - 2;
	}//End getPartnerIndex
	
	//remove card from hand by setting it to -1
	//and changing its image to null
	public void removeCard(int c)
	{
		for (int i = 0 ; i < hand.length; i++)
		{
			if (hand[i] == c)
			{
				hand[i] = -1;
				cards[i] = null;
			}
				
		}
				
	}//End removeCard
	
	//play card by returning it and removing it
	public int playCard(int c)
	{
		int temp = c;
		removeCard(c);
		return temp;
	}//End playCard
	
	//return player panel
	public PlayerPanel getPanel()
	{
		return pPanel;
	}//End getPanel
	
	//get team player is on
	public int getTeam()
	{
		return team;
	}//End getTeam
	
}//End Player class
